const express = require('express')
const app = express()
const PORT = process.env.PORT || 3333
const swgBackstage = require('./routes')
app.use(express.json())
app.use(express.urlencoded())

app.use('/api', swgBackstage)

// 错误中间件必须4个参数，即使用不到next
app.use(function (err, req, res, next) {
  console.error(err)
  res.status(500).json('something wrong')
})
app.listen(PORT, function () {
  console.log('Listen at http://localhost:3333')
})
